<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div th:include="fragment::headDiv"></div>
    <div th:replace="fragment::headDiv"></div>
    <div th:insert="fragment::headDiv"></div>
    <!--    获取域中的数据在页面中展示  -->
    <h4>获取域中数据展示</h4>
    <div th:text="${k1}"></div>
    <div th:text="${k2.msg+k2.code}"></div>
    <div th:text="${session.k4}"></div>
    <h4>字符串拼接</h4>
    <div th:text="${'msg:'+k2.msg+' code:'+k2.code}"></div>
    <div th:text="|msg:${k2.msg} code:${k2.code}|"></div>
<!--
    对象：自动拆包
        定义一个局部变量来接收域中获取的某个对象
        在它的子标签内 可以直接使用 *{}获取对象的属性值
-->
    <h4>对象拆包</h4>
    <div th:object="${k2}">
        <div th:text="*{msg}"></div>
        <div th:text="*{code}"></div>
    </div>
<!--
    遍历
-->
    <hr>
    <div th:each="obj,stat:${k3}" th:object="${obj}">
        <div th:text="${stat.index+1}"></div>
        <div th:text="*{msg==null?data:msg}"></div>
        <div th:text="*{code==0?'成功':'失败'}"></div>
    </div>
<!--
    路径拼接  路径一般使用@{}处理
-->
    <hr>
    <div>
        <a th:href="@{'http://api.gmall.com?id='+${k2.code}+'&keyword='+${k1}}">点击按钮1</a>
        <a th:href="@{http://api.gmall.com?id={id}&keyword={keyword}(id=${k2.code},keyword=${k1})}">点击按钮2</a>
        <a th:href="@{http://api.gmall.com(id=${k2.code},keyword=${k1})}">点击按钮3</a>
    </div>
<!--
    页面引入语法
    th:include:
            在使用th:include的标签内将页面片段引入
    th:replace
            替换使用th:replace的标签
    th:insert

-->

    <div th:include="fragment::footDiv"></div>
    <div th:replace="fragment::footDiv"></div>
    <div th:insert="fragment::footDiv"></div>
    <div th:insert="fragment:: #footDiv2"></div>
</body>
</html>